﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting;

namespace GameServer
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                Console.WriteLine(args[0]);
            }
            try
            {
                Console.WriteLine("**\tThis is game server.");
                Server srs = new Server();
                StartServer();
                Console.WriteLine("**\tGame server started successfuly.");
                Console.WriteLine("**\tListening at.");
                Console.WriteLine("**\tTcpChannel: " + srs.TcpPort.ToString());
                Console.WriteLine("/********************************************************/\n\n");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occured. Message: " + ex.Message);
            }

            Console.ReadLine();
        }

        public static void StartServer()
        {
            try
            {
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(Mediator), "GameServer.soap",
                    WellKnownObjectMode.Singleton);
            }
            catch (RemotingException ex)
            {
                Console.WriteLine(ex.Message);               
            }
        }
    }
}
